WITHDRAW_ANALYSIS_CONFIG = {
    'real_time_report': False,
    'target_event_id': ['withdraw', 'withdraw_financial', "withdraw_apply"],
    'interval_type_list': ['day', 'week', 'month'],
    'values': [
        {
            "value_id": "withdraw_user",
            "target_value": "_user_id",
            "value_name": "提现账号",
            "filter": [
                {'term': {'_event_id': 'withdraw'}},
            ],
            "operation": "cardinality",
            "value_type": "long"
        },
        {
            "value_id": "withdraw_count",
            "target_value": "withdraw_real_price",
            "value_name": "提现次数",
            "filter": [
                {'term': {'_event_id': 'withdraw'}},
            ],
            "operation": "value_count",
            "value_type": "long"
        },
        {
            "value_id": "withdraw_price",
            "target_value": "withdraw_real_price",
            "value_name": "提现金额",
            "filter": [
                {"term": {"_event_id": "withdraw"}},
            ],
            "value_type": "float",
            "adjust_amount": True,
        },
        {
            "value_id": "average_withdraw_price",
            "value_name": "人均提现金额",
            "value_expr": "withdraw_price / withdraw_user",
            "adjust_amount": True,
        },
        {
            "value_id": "price_per_withdraw",
            "value_name": "次均提现金额",
            "value_expr": "withdraw_price / withdraw_count",
            "adjust_amount": True,
        },
        {
            "value_id": "total_withdraw_count",
            "target_value": "_user_id",
            "value_name": "提现发起次数",
            "filter": [
                {"term": {"_event_id": "withdraw_apply"}}
            ],
            "operation": "value_count",
            "value_type": "long",
            "hide_result": True
        },
        {
            "value_id": "withdraw_success_rate",
            "value_name": "提现成功率",
            "value_expr": "withdraw_count / total_withdraw_count",
            "is_percentage": True,
            "fmt": lambda v: float("%.2f" % (v * 100))
        },
        {
            "value_id": "withdraw_failure_user",
            "target_value": "_user_id",
            "value_name": "提现失败账号",
            "filter": [
                {'term': {'_event_id': 'withdraw_financial'}},
                {'term': {'withdraw_financial_result': 'failure'}}
            ],
            "operation": "cardinality",
            "value_type": "long"
        },
        {
            "value_id": "withdraw_failure_count",
            "target_value": "_user_id",
            "value_name": "提现失败次数",
            "filter": [
                {'term': {'_event_id': 'withdraw_financial'}},
                {'term': {'withdraw_financial_result': 'failure'}}
            ],
            "operation": "value_count",
            "value_type": "long"
        },
        {
            "value_id": "alipay_withdraw_user",
            "target_value": "_user_id",
            "value_name": "支付宝提现账号",
            "filter": [
                {"term": {"_event_id": "withdraw"}},
                {"terms": {"withdraw_sub_type": ["alipay", "10"]}}
            ],
            "operation": "cardinality",
            "value_type": "long"
        },
        {
            "value_id": "alipay_withdraw",
            "target_value": "withdraw_real_price",
            "value_name": "支付宝提现金额",
            "filter": [
                {"term": {"_event_id": "withdraw"}},
                {"terms": {"withdraw_sub_type": ["alipay", "10"]}}
            ],
            "value_type": "float",
            "adjust_amount": True,
        },
        {
            "value_id": "unionagency_withdraw_user",
            "target_value": "_user_id",
            "value_name": "银行卡提现账号",
            "filter": [
                {"term": {"_event_id": "withdraw"}},
                {"terms": {"withdraw_sub_type": ["unionagency", "2"]}}
            ],
            "operation": "cardinality",
            "value_type": "long"
        },
        {
            "value_id": "unionagency_withdraw",
            "target_value": "withdraw_real_price",
            "value_name": "银行卡提现金额",
            "filter": [
                {"term": {"_event_id": "withdraw"}},
                {"terms": {"withdraw_sub_type": ["unionagency", "2"]}}
            ],
            "value_type": "float",
            "adjust_amount": True,
        }
    ]
}
